﻿<navigation:Page x:Class="Corina.Lantern.Hub.Views.Datas.ManualEntryView"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:localViewmodel="clr-namespace:Corina.Lantern.Hub.Viewmodels"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                 FontSize="14"
                 d:DesignHeight="560"
                 d:DesignWidth="960"
                 mc:Ignorable="d">

    <navigation:Page.DataContext>
        <localViewmodel:ManualEntryViewmodel />
    </navigation:Page.DataContext>

    <navigation:Page.Resources>
        <Style x:Key="STYLE_LABEL" TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Width" Value="120" />
            <Setter Property="FontSize" Value="15" />
        </Style>
    </navigation:Page.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid Visibility="{Binding ShowUpdate, Converter={StaticResource BooleanToVisibilityInverseConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            
            <toolkit:Expander Header="搜索数据"></toolkit:Expander>

            <StackPanel Grid.Row="1"
                        HorizontalAlignment="Right"
                        Orientation="Horizontal">
                <Button Margin="12,0"
                        Content="打印报表"
                        Style="{StaticResource GreenButton}" />

                <Button Command="{Binding InsertCommand}" Content="录入数据" />
            </StackPanel>

            <toolkit:BusyIndicator Grid.Row="2" IsBusy="{Binding IsBusy}" Margin="0,12">
                <sdk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding ItemsCollection}">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Binding="{Binding ItemIndex}" Header="序号" />
                        <sdk:DataGridTextColumn Binding="{Binding MeasureObject}" Header="检测项目" />
                        <sdk:DataGridTemplateColumn Header="浓度">
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock>
                                        <Run Text="{Binding Density}" />
                                        <Run Text=" " />
                                        <Run Text="{Binding DensityUnit}" />
                                    </TextBlock>

                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTextColumn Binding="{Binding Temperature}" Header="温度(℃)" />
                        <sdk:DataGridTextColumn Binding="{Binding Humidity}" Header="湿度(%)" />
                        <sdk:DataGridTextColumn Binding="{Binding Specimen}" Header="样品" />
                        <sdk:DataGridTextColumn Binding="{Binding SpecimenKind}" Header="样品种类" />
                        <sdk:DataGridTextColumn Binding="{Binding Guobiao}" Header="国标" />
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
            </toolkit:BusyIndicator>


        </Grid>

        <StackPanel Visibility="{Binding ShowUpdate, Converter={StaticResource BooleanToVisibilityConverter}}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <StackPanel>
                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="样品种类：" />
                        <!--  <TextBox Width="200" Text="{Binding Specimen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />  -->
                        <ComboBox Width="200"
                                  ItemsSource="{Binding SpecimenKindCollection}"
                                  SelectedItem="{Binding SelectedSpecimen,
                                                         Mode=TwoWay}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Title}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="样品：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.Specimen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="检测项目：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.MeasureObject, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="检测设备：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.MeasureDevice, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="浓度：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.Density, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        <ListBox Margin="6,0"
                                 Background="Transparent"
                                 BorderThickness="0"
                                 ItemsSource="{Binding DensityUnit}"
                                 SelectedItem="{Binding UpdateEntity.DensityUnit,
                                                        Mode=TwoWay}">
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <VirtualizingStackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.ItemContainerStyle>
                                <Style TargetType="ListBoxItem">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ListBoxItem">
                                                <RadioButton Margin="6,0"
                                                             Content="{Binding }"
                                                             IsChecked="{Binding IsSelected,
                                                                                 Mode=TwoWay,
                                                                                 RelativeSource={RelativeSource TemplatedParent}}" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ListBox.ItemContainerStyle>
                        </ListBox>
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="湿度（%）：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.Humidity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="温度（℃）：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.Temperature, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="检测时间：" />
                        <sdk:DatePicker Width="200" SelectedDate="{Binding UpdateEntity.MeasureTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        <toolkit:TimePicker Width="200"
                                            Margin="12,0"
                                            VerticalAlignment="Center"
                                            Value="{Binding UpdateEntity.MeasureTime,
                                                            Mode=TwoWay,
                                                            UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="检测人：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.Tester, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>


                </StackPanel>

                <StackPanel Grid.Column="1">
                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="送检人：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.Applicant, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="送检单位：" />
                        <TextBox Width="200" Text="{Binding UpdateEntity.ApplyUnit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <StackPanel Margin="0,12" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource STYLE_LABEL}" Text="送检时间：" />
                        <sdk:DatePicker Width="200" SelectedDate="{Binding UpdateEntity.ApplyDate.Date, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>
                </StackPanel>
            </Grid>
            <Rectangle Margin="0,12" Style="{StaticResource BreakLineStyle}" />

            <TextBlock Margin="120,0,0,0">
                <Run Foreground="Red" Text="*" />
                <Run Text="请如实填写以上各项数据，因数据填写错误引起的法律纠纷及财产损失，均与泊银科技无关！" />

            </TextBlock>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="320" />
                </Grid.ColumnDefinitions>

                <CheckBox Grid.Column="1"
                          Content="同意以上条款"
                          IsChecked="{Binding AgreePolicy,
                                              Mode=TwoWay}" />

                <StackPanel Grid.Column="2"
                            Margin="0,12"
                            Orientation="Horizontal">

                    <Button MinWidth="60"
                            Command="{Binding SubmitCommand}"
                            Content="提交"
                            Style="{StaticResource OrangeButton}" />
                    <Button MinWidth="60"
                            Margin="12,0"
                            Command="{Binding CancelCommand}"
                            Content="取消" />
                </StackPanel>
            </Grid>


        </StackPanel>
    </Grid>
</navigation:Page>
